<?php

namespace app\base\logic;



use app\base\model\LevelModel;

use app\base\model\setting\SettingBalanceModel;

use app\base\model\setting\SettingBuyModel;

use app\base\model\setting\SettingIntegralModel;

use app\base\model\setting\SettingSmsModel;

use app\common\logic\DataSettingLogic;

use app\base\logic\LogsLogic;

class ShopInitLogic{

    

    public static function init($shop_id){

        //会员等级

//        $level=new LevelModel();
//
//        $levelData=[
//
//            ['shop_id'=>$shop_id,'name'=>'白银会员','vip_level'=>2,'need_integral'=>2000,'need_recharge'=>1600,'discount'=>8,'is_base'=>1],
//
//            ['shop_id'=>$shop_id,'name'=>'白金会员','vip_level'=>3,'need_integral'=>3000,'need_recharge'=>2400,'discount'=>7,'is_base'=>1],
//
//            ['shop_id'=>$shop_id,'name'=>'黄金会员','vip_level'=>4,'need_integral'=>4000,'need_recharge'=>3200,'discount'=>6,'is_base'=>1],
//
//        ];
//
//        $level->saveAll($levelData);



        //余额设置

        $setting_balance = new SettingBalanceModel();

        $setting_balance->shop_id=$shop_id;

        $setting_balance->taocan_detail=[];

        $setting_balance->save();



        //积分设置

        $setting_integral = new SettingIntegralModel();

        $setting_integral->shop_id=$shop_id;

        $setting_integral->save();



        //买单设置

        $setting_buy = new SettingBuyModel();

        $setting_buy->shop_id=$shop_id;

        $setting_buy->save();



        //短信设置

        $DataSetting =  new DataSettingLogic();

        $sms=$DataSetting->getData('sms');

        $setting_sms = new SettingSmsModel();

        $setting_sms->shop_id =$shop_id;

        $setting_sms->sms_num = $sms['give_num'];

        $setting_sms->boss_mobiles=[];

        $setting_sms->save();

        if($sms['give_num'] > 0){

            LogsLogic::smsRecharge($shop_id,2,$sms['give_num'],0);      

        }

        //插入短信记录



        return true;

    }

    

}